Optimal. Leaf size=386 \[ -\frac {\left (3-4 m+m^2\right ) \left (i B \left (1-m^2\right )-A \left (1-4 m+m^2\right )\right ) \, _2F_1\left (1,\frac {1+m}{2};\frac {3+m}{2};-\tan ^2(c+d x)\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+m)}-\frac {\left (i B \left (1+3 m-m^2\right )-A \left (13-7 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+i \tan (c+d x))^2}-\frac {(2-m) \left (i B \left (2+2 m-m^2\right )-A \left (8-6 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+i \tan (c+d x))}+\frac {(2-m) m \left (B \left (2+2 m-m^2\right )+i A \left (8-6 m+m^2\right )\right ) \, _2F_1\left (1,\frac {2+m}{2};\frac {4+m}{2};-\tan ^2(c+d x)\right ) \tan ^{2+m}(c+d x)}{48 a^4 d (2+m)}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{8 d (a+i a \tan (c+d x))^4}+\frac {(i B (1-m)+A (5-m)) \tan ^{1+m}(c+d x)}{24 a d (a+i a \tan (c+d x))^3} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.86, antiderivative size = 386, normalized size of antiderivative = 1.00, number of steps
used = 9, number of rules used = 4, integrand size = 34, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.118, Rules used = {3677, 3619,
3557, 371} \begin {gather*} -\frac {\left (m^2-4 m+3\right ) \left (-A \left (m^2-4 m+1\right )+i B \left (1-m^2\right )\right ) \tan ^{m+1}(c+d x) \, _2F_1\left (1,\frac {m+1}{2};\frac {m+3}{2};-\tan ^2(c+d x)\right )}{48 a^4 d (m+1)}+\frac {(2-m) m \left (B \left (-m^2+2 m+2\right )+i A \left (m^2-6 m+8\right )\right ) \tan ^{m+2}(c+d x) \, _2F_1\left (1,\frac {m+2}{2};\frac {m+4}{2};-\tan ^2(c+d x)\right )}{48 a^4 d (m+2)}-\frac {(2-m) \left (-A \left (m^2-6 m+8\right )+i B \left (-m^2+2 m+2\right )\right ) \tan ^{m+1}(c+d x)}{48 a^4 d (1+i \tan (c+d x))}-\frac {\left (-A \left (m^2-7 m+13\right )+i B \left (-m^2+3 m+1\right )\right ) \tan ^{m+1}(c+d x)}{48 a^4 d (1+i \tan (c+d x))^2}+\frac {(A (5-m)+i B (1-m)) \tan ^{m+1}(c+d x)}{24 a d (a+i a \tan (c+d x))^3}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{8 d (a+i a \tan (c+d x))^4} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 371
Rule 3557
Rule 3619
Rule 3677
Rubi steps
\begin {align*} \int \frac {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^4} \, dx &=\frac {(A+i B) \tan ^{1+m}(c+d x)}{8 d (a+i a \tan (c+d x))^4}+\frac {\int \frac {\tan ^m(c+d x) (a (A (7-m)-i B (1+m))-a (i A-B) (3-m) \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx}{8 a^2}\\ &=\frac {(A+i B) \tan ^{1+m}(c+d x)}{8 d (a+i a \tan (c+d x))^4}+\frac {(i B (1-m)+A (5-m)) \tan ^{1+m}(c+d x)}{24 a d (a+i a \tan (c+d x))^3}+\frac {\int \frac {\tan ^m(c+d x) \left (-2 a^2 \left (i B \left (4+3 m-m^2\right )-A \left (16-7 m+m^2\right )\right )+2 a^2 (B (1-m)-i A (5-m)) (2-m) \tan (c+d x)\right )}{(a+i a \tan (c+d x))^2} \, dx}{48 a^4}\\ &=-\frac {\left (i B \left (1+3 m-m^2\right )-A \left (13-7 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+i \tan (c+d x))^2}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{8 d (a+i a \tan (c+d x))^4}+\frac {(i B (1-m)+A (5-m)) \tan ^{1+m}(c+d x)}{24 a d (a+i a \tan (c+d x))^3}+\frac {\int \frac {\tan ^m(c+d x) \left (4 a^3 \left (A \left (19-20 m+8 m^2-m^3\right )-i B \left (7+2 m-4 m^2+m^3\right )\right )-4 a^3 (1-m) \left (B \left (1+3 m-m^2\right )+i A \left (13-7 m+m^2\right )\right ) \tan (c+d x)\right )}{a+i a \tan (c+d x)} \, dx}{192 a^6}\\ &=-\frac {\left (i B \left (1+3 m-m^2\right )-A \left (13-7 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+i \tan (c+d x))^2}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{8 d (a+i a \tan (c+d x))^4}+\frac {(i B (1-m)+A (5-m)) \tan ^{1+m}(c+d x)}{24 a d (a+i a \tan (c+d x))^3}-\frac {(2-m) \left (i B \left (2+2 m-m^2\right )-A \left (8-6 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 d \left (a^4+i a^4 \tan (c+d x)\right )}+\frac {\int \tan ^m(c+d x) \left (-8 a^4 \left (3-4 m+m^2\right ) \left (i B \left (1-m^2\right )-A \left (1-4 m+m^2\right )\right )+8 a^4 (2-m) m \left (B \left (2+2 m-m^2\right )+i A \left (8-6 m+m^2\right )\right ) \tan (c+d x)\right ) \, dx}{384 a^8}\\ &=-\frac {\left (i B \left (1+3 m-m^2\right )-A \left (13-7 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+i \tan (c+d x))^2}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{8 d (a+i a \tan (c+d x))^4}+\frac {(i B (1-m)+A (5-m)) \tan ^{1+m}(c+d x)}{24 a d (a+i a \tan (c+d x))^3}-\frac {(2-m) \left (i B \left (2+2 m-m^2\right )-A \left (8-6 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 d \left (a^4+i a^4 \tan (c+d x)\right )}+\frac {\left ((2-m) m \left (B \left (2+2 m-m^2\right )+i A \left (8-6 m+m^2\right )\right )\right ) \int \tan ^{1+m}(c+d x) \, dx}{48 a^4}-\frac {\left (\left (3-4 m+m^2\right ) \left (i B \left (1-m^2\right )-A \left (1-4 m+m^2\right )\right )\right ) \int \tan ^m(c+d x) \, dx}{48 a^4}\\ &=-\frac {\left (i B \left (1+3 m-m^2\right )-A \left (13-7 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+i \tan (c+d x))^2}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{8 d (a+i a \tan (c+d x))^4}+\frac {(i B (1-m)+A (5-m)) \tan ^{1+m}(c+d x)}{24 a d (a+i a \tan (c+d x))^3}-\frac {(2-m) \left (i B \left (2+2 m-m^2\right )-A \left (8-6 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 d \left (a^4+i a^4 \tan (c+d x)\right )}+\frac {\left ((2-m) m \left (B \left (2+2 m-m^2\right )+i A \left (8-6 m+m^2\right )\right )\right ) \text {Subst}\left (\int \frac {x^{1+m}}{1+x^2} \, dx,x,\tan (c+d x)\right )}{48 a^4 d}-\frac {\left (\left (3-4 m+m^2\right ) \left (i B \left (1-m^2\right )-A \left (1-4 m+m^2\right )\right )\right ) \text {Subst}\left (\int \frac {x^m}{1+x^2} \, dx,x,\tan (c+d x)\right )}{48 a^4 d}\\ &=-\frac {\left (3-4 m+m^2\right ) \left (i B \left (1-m^2\right )-A \left (1-4 m+m^2\right )\right ) \, _2F_1\left (1,\frac {1+m}{2};\frac {3+m}{2};-\tan ^2(c+d x)\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+m)}-\frac {\left (i B \left (1+3 m-m^2\right )-A \left (13-7 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 a^4 d (1+i \tan (c+d x))^2}+\frac {(2-m) m \left (B \left (2+2 m-m^2\right )+i A \left (8-6 m+m^2\right )\right ) \, _2F_1\left (1,\frac {2+m}{2};\frac {4+m}{2};-\tan ^2(c+d x)\right ) \tan ^{2+m}(c+d x)}{48 a^4 d (2+m)}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{8 d (a+i a \tan (c+d x))^4}+\frac {(i B (1-m)+A (5-m)) \tan ^{1+m}(c+d x)}{24 a d (a+i a \tan (c+d x))^3}-\frac {(2-m) \left (i B \left (2+2 m-m^2\right )-A \left (8-6 m+m^2\right )\right ) \tan ^{1+m}(c+d x)}{48 d \left (a^4+i a^4 \tan (c+d x)\right )}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(921\) vs. \(2(386)=772\).
time = 50.77, size = 921, normalized size = 2.39 \begin {gather*} -\frac {i e^{-4 i c} \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \left (\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )^{-m} \left (3 (A+i B) e^{-8 i d x} \left (-1+e^{2 i (c+d x)}\right )^{1+m} \left (1+e^{2 i (c+d x)}\right )^{4-m}+e^{2 i (c-3 d x)} \left (-1+e^{2 i (c+d x)}\right )^{1+m} \left (1+e^{2 i (c+d x)}\right )^{4-m} (A (7-2 m)-i (B+2 B m))-e^{4 i (c-d x)} \left (-1+e^{2 i (c+d x)}\right )^{1+m} \left (1+e^{2 i (c+d x)}\right )^{4-m} \left (i B \left (3+2 m-2 m^2\right )+A \left (-9+10 m-2 m^2\right )\right )+\frac {e^{-2 i (-3 c+d x)} \left (-1+e^{2 i (c+d x)}\right )^{1+m} \left (1+e^{2 i (c+d x)}\right )^{4-m} m (1+m) \left (A \left (13-44 m+26 m^2-4 m^3\right )-i B \left (7-4 m-10 m^2+4 m^3\right )\right )-2^{5-m} e^{8 i c} \left (-1+e^{2 i (c+d x)}\right )^{1+m} m \left (A \left (13-44 m+26 m^2-4 m^3\right )-i B \left (7-4 m-10 m^2+4 m^3\right )\right ) \, _2F_1\left (-3+m,1+m;2+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )+2^{2-m} e^{8 i c} \left (\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )^m \left (A \left (3-32 m+40 m^2-16 m^3+2 m^4\right )+i B \left (-3+8 m+4 m^2-8 m^3+2 m^4\right )\right ) \left (-2^m (1+m) \, _2F_1\left (1,m;1+m;\frac {1-e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )+\left (1+e^{2 i (c+d x)}\right )^m \left (4 \left (-1+e^{2 i (c+d x)}\right ) m \, _2F_1\left (-2+m,1+m;2+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )+2 \left (-1+e^{2 i (c+d x)}\right ) m \, _2F_1\left (-1+m,1+m;2+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )+\, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )+m \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )-m \, _2F_1\left (m,1+m;2+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )+e^{2 i (c+d x)} m \, _2F_1\left (m,1+m;2+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )\right )\right )}{m (1+m)}\right ) \sec ^3(c+d x) (\cos (d x)+i \sin (d x))^4 (A+B \tan (c+d x))}{384 d (A \cos (c+d x)+B \sin (c+d x)) (a+i a \tan (c+d x))^4} \end {gather*}
Warning: Unable to verify antiderivative.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.51, size = 0, normalized size = 0.00 \[\int \frac {\left (\tan ^{m}\left (d x +c \right )\right ) \left (A +B \tan \left (d x +c \right )\right )}{\left (a +i a \tan \left (d x +c \right )\right )^{4}}\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: RuntimeError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \frac {\int \frac {A \tan ^{m}{\left (c + d x \right )}}{\tan ^{4}{\left (c + d x \right )} - 4 i \tan ^{3}{\left (c + d x \right )} - 6 \tan ^{2}{\left (c + d x \right )} + 4 i \tan {\left (c + d x \right )} + 1}\, dx + \int \frac {B \tan {\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}}{\tan ^{4}{\left (c + d x \right )} - 4 i \tan ^{3}{\left (c + d x \right )} - 6 \tan ^{2}{\left (c + d x \right )} + 4 i \tan {\left (c + d x \right )} + 1}\, dx}{a^{4}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.00 \begin {gather*} \int \frac {{\mathrm {tan}\left (c+d\,x\right )}^m\,\left (A+B\,\mathrm {tan}\left (c+d\,x\right )\right )}{{\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^4} \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________